home *** CD-ROM | disk | FTP | other *** search
- ;;******************************************************************
- ;;使用例: memdump es,[20h]
- memdump macro _sreg,_oadr
- push ebx
-
- lea ebx,_oadr
- mov ebp,_sreg ;;sregにebxと渡すのは駄目
- call _proc_memdump
-
- pop ebx
- endm
- align 4
- _proc_memdump proc
- push es
- push eax
- push ecx
- push edx
- push esi
- mov es,ebp ;;es:ebxの16アラインを読み込む
-
- nummsg freework[20],ebp ;;es=eax
- mov byte ptr freework[28],":" ;;$の代わりに
- nummsg freework[29],ebx ;;offset
- cutzero freework[20]
-
- lea edx,byte ptr [freework+20]
- mov ah,9h
- int 21h
-
- lea edx,#green
- mov ah,9h
- int 21h
-
- mov ecx,16
- mov dword ptr freework[56]," "
- xor esi,esi
- xor ebp,ebp
- #l1:
- mov al,es:[ebx+esi]
- ;;そのままの表示(右端)
- cmp al,20h
- jae short #canview
- #cannotview:
- mov byte ptr freework[60+esi],"."
- jmp short #viewterm
- #canview:
- mov freework[60+esi],al
- #viewterm:
-
- ;;--bit setup
- mov ah,al
- and ax,0000111111110000b
- shr al,4
- #_high_bit_processing:
- cmp ah,0ah
- jb short #_h_underten
- add ah,37h
- jmp short #_low_bit_processing
- #_h_underten:
- add ah,30h
-
- #_low_bit_processing:
- cmp al,0ah
- jb short #_l_underten
- add al,37h
- jmp short #_processend
- #_l_underten:
- add al,30h
-
- #_processend:
- mov word ptr freework[40],ax
- mov byte ptr freework[40+2],"$"
- cmp ebp,4
- je short #putbar
- mov ah,2h
- mov dl," "
- int 21h
- #asciiprint:
- lea edx,freework[40]
- mov ah,9h
- int 21h
- inc esi
- inc ebp
- loop #l1
-
- lea edx,#white
- mov ah,9h
- int 21h
-
- mov ah,40h ;;初めの8文字+1
- mov bx,1
- mov ecx,9
- lea edx,freework[59]
- int 21h
-
- mov ah,9
- lea edx,#bar
- int 21h
- lea edx,#white
- int 21h
-
- add ecx,2
- mov word ptr freework[76],0a0dh
- mov ah,40h
- lea edx,freework[68]
- int 21h
- ;;ダンプの数値[39]は毎回表示。文字本体[59]-[69]は一気に表示
- pop esi
- pop edx
- pop ecx
- pop eax
- pop es
- ret
- #putbar:
- lea edx,#bar
- mov ah,9h
- int 21h
- mov ebp,0
- jmp short #asciiprint
-
- #white db 1bh,"[37m$"
- #green db 1bh,"[32m$"
- #bar db 1bh,"[1;7;31m"," ",1bh,"[0;32m$"
- _proc_memdump endp
-
- nummsg macro para2,para1 ;;para1=32bit数(4byte) para2=文字格納adr
- ;; =(32bit)=4byte=0.ff.ff.ff.ff.h
- ;;よって文字は8+$で 9byte確保必要
- pushad
- ;;完璧なパラメータ受渡しをしている。
- mov dword ptr freework,eax ;;eaxの初期状況保存
-
- mov eax,para1 ;;eaxが破壊
- push eax
-
- mov eax,dword ptr freework ;;再状況設定
- lea ebx,para2
-
- pop eax ;;受取済をロード
- call _proc_nummsg
- popad
- endm
-
- cutzero macro para2 ;;"0"を0にする
- push ebx
- lea ebx,para2
- call _proc_cutzero
- pop ebx
- endm
- align 4
- _proc_cutzero proc
- #cnvzero1:
- cmp byte ptr [ebx],"0"
- je #cnvzero2
-
- jmp short #macroexit2
-
- #cnvzero2: ;;置き換え
- mov byte ptr [ebx],0
- inc ebx
- jmp short #cnvzero1
-
- #macroexit2:
- cmp byte ptr [ebx],"$"
- jne #cnvzero3
- mov byte ptr [ebx-1],"0"
- #cnvzero3:
- ret
- _proc_cutzero endp
-
- ;;*******************************************************************
- align 4
- _proc_nummsg proc ;;ebx=格納先アドレス eax=数値
- push ecx
- push edx
- push esi
-
- mov esi,10000000h ;;esiで割る
- mov ecx,8
- align 4
- #dword1:
- push ecx
-
- mov edx,0
- div esi ;;eax/diver(=esi)
-
- add eax,30h
- cmp al,3ah
- jb short #under_ten
- add eax,7
- #under_ten:
- mov byte ptr [ebx],al ;;商の文字を転写
-
-
- shr esi,4 ;;HEX一つ右にずらす
-
- inc ebx ;;商の文字の格納先を一つずらす。
-
- mov eax,edx ;;余りを転写
-
- pop ecx
- loop #dword1
-
- mov byte ptr [ebx],"$"
- pop esi
- pop edx
- pop ecx
- ret
- _proc_nummsg endp
-
- ;;*******************************************************************
-
- FREEWORK db 128 dup(0)
-
- ;;*******************************************************************
- ;;ファイル先頭にあるように、
- ;; ES,[ESI]
- ;;などとして使って下さい。[]を忘れないように。
- ;;尚、セグメントレジスタにeaxなどと言う指定もできない訳ではないですが、
- ;; ebxを使うのはお避け下さい。確実に失敗します。
- ;;あと、FREEWORKについては、ローカル#FREEWORKにした方がいいかも知れません
- ;;当然の事ですが、DSはFREEWORKを含むセグメントにしてくださいね
- ;; (DSを変更したままにする人はあまり無いと思うけど)
-